//
//  HABaseVC.m
//  HA
//
//  Created by sy on 2023/12/17.
//

#import "HABaseVC.h"

@interface HABaseVC ()

@end

@implementation HABaseVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor khaBGColor];
    [self.navigationController.navigationBar setBarTintColor:[UIColor whiteColor]];
    
    self.navigationController.navigationBarHidden = YES;
    
    [[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
    [UITableView appearance].contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    /*
     IOS11以后，Self-Sizing默认开启，包括Headers, footers。
     如果项目中没使用estimatedRowHeight属性，在IOS11下会有奇奇怪怪的现象，
     因为IOS11之前，estimatedRowHeight默认为0，Self-Sizing自动打开后，
     contentSize和contentOffset都可能发生改变。可以通过以下方式禁用：
     */
    [UITableView appearance].estimatedRowHeight = 0;
    [UITableView appearance].estimatedSectionHeaderHeight = 0;
    [UITableView appearance].estimatedSectionFooterHeight = 0;

    [self po_setUpUI];

    // Do any additional setup after loading the view.
}

- (BOOL)gestureRecognizerShouldBegin {
    return YES;
}

- (void)po_setUpUI{
    
    [self.baseNavView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(self.view);
        make.height.mas_offset(app_topH+44);
    }];

    [self.baseLButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@5);
        make.top.equalTo(self.baseNavView).offset(app_topH+2);
        make.size.equalTo(@40);
    }];
    [self.baseRButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-5);
        make.centerY.equalTo(self.baseLButton);
        make.size.equalTo(@40);
    }];

    [self.baseTLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.baseLButton).offset(0);
        make.left.equalTo(self.baseNavView).offset(45);
        make.right.equalTo(self.baseNavView).offset(-45);
        make.centerX.equalTo(self.baseNavView);
    }];
}


-(void)ha_leftButtonClick {
    if ([NSThread isMainThread]) {
        [self.navigationController popViewControllerAnimated:YES];
    } else {
        WS(weakSelf)
        dispatch_async(dispatch_get_main_queue(), ^{
            [weakSelf.navigationController popViewControllerAnimated:YES];
        });
    }
}

-(void)yg_rightButtonClick {
    
}

- (UIImageView *)baseNavView{
    if (!_baseNavView) {
        _baseNavView = [[UIImageView alloc] init];
        _baseNavView.userInteractionEnabled = YES;
        _baseNavView.image = [UIImage imageWithColor:[UIColor colorWithHexString:@"#FFFFFF"]];
        [self.view addSubview:_baseNavView];

    }
    return _baseNavView;
}

- (UILabel *)baseTLabel{
    if (!_baseTLabel) {
        _baseTLabel = [[UILabel alloc] init];
        _baseTLabel.textAlignment = 1;
        _baseTLabel.textColor = [UIColor colorWithHexString:@"#303133"];
        _baseTLabel.font = [UIFont boldSystemFontOfSize:20];
        [self.baseNavView addSubview:_baseTLabel];

    }
    return _baseTLabel;
}

- (UIButton *)baseLButton{
    if (!_baseLButton) {
        _baseLButton = [[UIButton alloc] init];
        [_baseLButton setTitleColor:[UIColor colorWithHexString:@"#373737"] forState:UIControlStateNormal];
        [_baseLButton setImage:[UIImage imageNamed:@"back1"] forState:UIControlStateNormal];
        [_baseLButton addTarget:self action:@selector(ha_leftButtonClick) forControlEvents:UIControlEventTouchUpInside];
        [self.baseNavView addSubview:_baseLButton];

    }
    return _baseLButton;
}
- (UIButton *)baseRButton{
    if (!_baseRButton) {
        _baseRButton = [[UIButton alloc] init];
        _baseRButton.titleLabel.font = [UIFont systemFontOfSize:14];
        [_baseRButton setTitleColor:[UIColor colorWithHexString:@"#373737"] forState:UIControlStateNormal];
        [_baseRButton addTarget:self action:@selector(yg_rightButtonClick) forControlEvents:UIControlEventTouchUpInside];
        [self.baseNavView addSubview:_baseRButton];

    }
    return _baseRButton;
}


@end
